<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>来款自动核销 管理</title>
    <style type="text/css">
    </style>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="field">
                        <span id="autoVerifyBtn" class="sq-button sq-button-hasicon"><i class="sqBtnIco_3"></i>批量分解</span>
                    </div>
                </div>
            </div>
        </form>
    </div>

    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null, menu = null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/capital/capFund/initList.do',
            parms:{fundCd:0,fundStatusCD:"0,1"},
            method: 'get',
            columns: [
                {display: '资金编号', name: 'id', minWidth: 100, align: 'center', enabledSort: false},
                {display: '收款账号', name: 'acceptCode', minWidth: 100, align: 'left', enabledSort: false},
                {display: '来款户名', name: 'comeName', minWidth: 100, align: 'center', enabledSort: false},
                {display: '收到金额', name: 'amount', minWidth: 100, align: 'right', enabledSort: false,
                    render:function(rowdata,index,value){
                        return FormatMoney(rowdata.amount/100);
                    }
                },
                {display: '摘要', name: 'docketRem', minWidth: 100, align: 'left', enabledSort: false},
                {display: '到账日期', name: 'acceptDate', minWidth: 100, align: 'center', enabledSort: false,render:renderDate},
                {display: '创建时间', name: 'crtTm', minWidth: 100, align: 'center', enabledSort: false,render:renderDate},
                {display: '认款人', name: 'identifyOperatorNm', minWidth: 100, align: 'center', enabledSort: false},
            ],
            pageSize: 50,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true
        });
        grid.setHeight(100);

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "*Cd": " "
            });
        });
        
        var callback = function () {
            grid.reload();
        };

        /* 自动分解 */
        $("#autoVerifyBtn").click(function (event) {
            var selectedRows = grid.getSelectedRows();
            if (selectedRows.length == 0) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_MORE_ROW, SQ_type: "warning"});
                return;
            }
            var _ids = [];
            for (var index in selectedRows) {
                _ids.push(selectedRows[index].id);
            }
            $.ligerDialog.confirm("是否确认自动分解选中资金数据?", function (flag) {
                if (flag == false)return;
                var wait_dialog;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {ids: JSON.stringify(_ids)},
                    url: '',
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({
                            content: LogUtils.LOG_CMM_DATA_LOADING,
                            SQ_type: "waitting"
                        });
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            grid.reload();
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                        }
                    }
                });
            });
        });
    });


    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

</script>

</body>
</html>
